package com.ruoyi.ldzlsc.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.ldzlsc.domain.dto.DispatchCreateDto;
import com.ruoyi.ldzlsc.domain.vo.MaterialRequirementVo;
import com.ruoyi.ldzlsc.service.IScDispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 生产派工Controller
 *
 * @author ldzl
 */
@RestController
@RequestMapping("/dispatch")
public class ScDispatchController extends BaseController {

    @Autowired
    private IScDispatchService scDispatchService;

    /**
     * 根据工序任务ID获取物料需求清单
     */
    @GetMapping("/material/{workOrderTaskId}")
    public AjaxResult getMaterialRequirements(@PathVariable Long workOrderTaskId) {
        List<MaterialRequirementVo> list = scDispatchService.getMaterialRequirements(workOrderTaskId);
        return AjaxResult.success(list);
    }

    /**
     * 新增生产派工
     */
    @PostMapping
    public AjaxResult createDispatch(@RequestBody DispatchCreateDto dto) {
        return toAjax(scDispatchService.createDispatch(dto));
    }
} 